package com.hc;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
    private static String driverClassName;
    private static String url;
    private static String username;
    private static String password;
    private static String initialSize;
    private static String maxActive;
    private static String maxIdle;
    private static String minIdle;

    static {
        InputStream inputStream = PropertiesUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
        Properties properties = new Properties();
        try{
            properties.load(inputStream);
            driverClassName = properties.getProperty("driverClassName");
            url = properties.getProperty("url");
            username = properties.getProperty("username");
            password = properties.getProperty("password");
            initialSize = properties.getProperty("initialSize");
            maxActive = properties.getProperty("maxActive");
            maxIdle = properties.getProperty("maxIdle");
            minIdle = properties.getProperty("minIdle");
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if(inputStream != null){
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static String getDriverClassName() {
        return driverClassName;
    }

    public static String getUrl() {
        return url;
    }

    public static String getUsername() {
        return username;
    }

    public static String getPassword() {
        return password;
    }

    public static String getInitialSize() {
        return initialSize;
    }

    public static String getMaxActive() {
        return maxActive;
    }

    public static String getMaxIdle() {
        return maxIdle;
    }

    public static String getMinIdle() {
        return minIdle;
    }
}
